#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
简单的文件结构检查脚本
"""

import os

def check_files():
    """检查必需文件是否存在"""
    print("=" * 60)
    print("分析结果模块文件结构检查")
    print("=" * 60)
    
    required_files = [
        "templates/ai-analysis/results-tab.html",
        "static/js/pages/ai-analysis/analysis-results-manager.js",
        "static/css/pages/ai-analysis/analysis-results.css",
        "api/analysis_results_new.py"
    ]
    
    print("\n检查文件存在性...")
    for file_path in required_files:
        if os.path.exists(file_path):
            print(f"[OK] {file_path} 存在")
        else:
            print(f"[ERROR] {file_path} 不存在")
    
    # 检查主页面是否包含分析结果标签
    print("\n检查主页面集成...")
    try:
        with open("templates/ai-analysis/index.html", "r", encoding="utf-8") as f:
            content = f.read()
            if "分析结果" in content and "results" in content:
                print("[OK] 主页面已集成分析结果标签")
            else:
                print("[ERROR] 主页面未正确集成分析结果标签")
    except Exception as e:
        print(f"[ERROR] 检查主页面失败: {e}")
    
    # 检查主控制器是否包含分析结果管理器
    print("\n检查主控制器集成...")
    try:
        with open("static/js/pages/ai-analysis/main.js", "r", encoding="utf-8") as f:
            content = f.read()
            if "AnalysisResultsManager" in content and "results" in content:
                print("[OK] 主控制器已集成分析结果管理器")
            else:
                print("[ERROR] 主控制器未正确集成分析结果管理器")
    except Exception as e:
        print(f"[ERROR] 检查主控制器失败: {e}")
    
    # 检查CSS是否被正确引入
    print("\n检查CSS样式引入...")
    try:
        with open("templates/ai-analysis/index.html", "r", encoding="utf-8") as f:
            content = f.read()
            if "analysis-results.css" in content:
                print("[OK] CSS样式文件已正确引入")
            else:
                print("[ERROR] CSS样式文件未正确引入")
    except Exception as e:
        print(f"[ERROR] 检查CSS引入失败: {e}")
    
    # 检查JavaScript文件是否被正确引入
    print("\n检查JavaScript文件引入...")
    try:
        with open("templates/ai-analysis/index.html", "r", encoding="utf-8") as f:
            content = f.read()
            if "analysis-results-manager.js" in content:
                print("[OK] JavaScript管理器文件已正确引入")
            else:
                print("[ERROR] JavaScript管理器文件未正确引入")
    except Exception as e:
        print(f"[ERROR] 检查JavaScript引入失败: {e}")
    
    print("\n" + "=" * 60)
    print("检查完成")
    print("=" * 60)

if __name__ == "__main__":
    check_files()